﻿using System;
using System.Collections.Generic;
using System.Collections.Specialized;

namespace Sharp.Portal.Other
{
    /// <summary>
    /// 工具栏按钮
    /// </summary>
    public class ToolButtonInfo
    {

        /// <summary>
        /// 工具栏按钮 构造函数
        /// </summary>
        public ToolButtonInfo()
        {
            Mode = string.Empty;
            Title = string.Empty;
            Icon = string.Empty;
            Url = string.Empty;
            IsIFrameStyle = 0;

            WithoutId = true;
            IsSendParentId = true;
            Parameters = new List<Parameter>();
            ClientClickExtraParams = new Dictionary<string, string>();
        }

        /// <summary>
        /// 数据处理器模式，用于和浏览器之间传递处理指令
        /// </summary>
        public string Mode { get; set; }

        /// <summary>
        /// 数据处理器名称（按钮标题）
        /// </summary>
        public string Title { get; set; }

        /// <summary>
        /// 图标
        /// </summary>
        public string Icon { get; set; }

        /// <summary>
        /// 模块ID或者Iframe Url
        /// </summary>
        public string Url { get; set; }
        /// <summary>
        /// Action名称
        /// </summary>
        /// <example>可以接受GetPaged或者GetPaged,User。它会自己转换为Url.Action相关形式</example>
        public string UrlAction { get; set; }
        /// <summary>
        /// Iframe Style
        /// 0：以iframe打开链接；1：以窗体打开链接；2：url的资源是否当作js来执行
        /// </summary>
        public int IsIFrameStyle { get; set; }

        /// <summary>
        ///  Ajax请求，无窗体
        /// </summary>
        public bool IsAjax { get; set; }

        /// <summary>
        /// 窗体宽度
        /// </summary>
        public int Width { get; set; }

        /// <summary>
        /// 窗体高度
        /// </summary>
        public int Height { get; set; }

        /// <summary>
        /// 不需要发送数据记录 ID
        /// </summary>
        public bool WithoutId { get; set; }
        /// <summary>
        /// 是否有窗口
        /// </summary>
        public bool HasWindow;
        /// <summary>
        /// 发送ParentId
        /// </summary>
        public bool IsSendParentId { get; set; }
        /// <summary>
        /// 客户端点击
        /// </summary>
        public string OnClientClick { get; set; }
         /// <summary>
         /// 客户端点击额外参数
         /// </summary>
        public Dictionary<string, string> ClientClickExtraParams { get; set; }
        /// <summary>
        /// 将要渲染的Html
        /// </summary>
        public string Html { get; set; }
        /// <summary>
        /// 引导
        /// </summary>
        public DirectClickAction Direct  { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public IList<Parameter> Parameters { get; set; }
        /// <summary>
        /// 点击的Url配置
        /// </summary>
        public class DirectClickAction
        {
            /// <summary>
            /// 点击的Url配置
            /// </summary>
            /// <param name="actionName"></param>
            /// <param name="controllerName"></param>
            public DirectClickAction(string actionName, string controllerName)
            {
                ControllerName = controllerName;
                ActionName = actionName;
            }
            /// <summary>
            /// Controller名称
            /// </summary>
            public string ControllerName { get; set; }
            /// <summary>
            /// 动作名称
            /// </summary>
            public string ActionName { get; set; }

        }
        /// <summary>
        /// 参数实体
        /// </summary>
        public class Parameter
        {
            /// <summary>
            /// 参数实体
            /// </summary>
            /// <param name="name"></param>
            /// <param name="value"></param>
            /// <param name="mode">类似Ext.net的ParameterMode枚举</param> 
            public Parameter(string name, string value, int mode)
            {
                Name = name;
                Value = value;
                Mode = mode;
            }
            /// <summary>
            /// 名称
            /// </summary>
            public string Name { get; set; }
            /// <summary>
            /// 值或表达式
            /// </summary>
            public string Value { get; set; }
            /// <summary>
            /// 模式
            /// </summary>
            public int Mode { get; set; }
        }
    }
}